layui.use(['layer','jquery','form','table','laydate'],function () {
    let form = layui.form;
    let layer = layui.layer;
    let $ = layui.$;
    let table = layui.table;
    let laydate = layui.laydate;
    //返回功能
    $('#goBack').click(function () {
        parent.tabParentChange(3);
    })
    //操作时间渲染
    laydate.render({
        elem: '#updateDate',
        type: 'datetime'
    });
    //刷新功能
    $('#refresh').click(function () {
        location.reload();
    });
    getCourseHistoryDetails();
    //根据课程id、课程名字、操作时间查询课程历史详情记录
    form.on('submit(search)',function (obj) {
        getCourseHistoryDetails(obj.field)
        return false;
    });
    function getCourseHistoryDetails(historyDetails) {
        $.ajax({
            url: '/courseJournal/getCourseHistoryDetails',
            data: historyDetails,
            dataType: 'json',
            success: function (data) {
                courseHistoryDetails(data.data);
            }
        });
    }
    function courseHistoryDetails(courseHistoryDetails) {
        table.render({
            elem: '#historyPriceTable',
            title: '课程列表',
            data: courseHistoryDetails,
            limit: 10,
            toolbar: '#course_thead',
            page: {
                layout: ['count', 'prev', 'page', 'next', 'limit', 'skip', 'refresh'],
                //limits:[3,6,9],
                first: "首页",
                last: "尾页",
            },
            cols: [[
                {type:'checkbox'},
                {title:'序号',align:'center',templet:function(data){
                    return data.LAY_INDEX;
                }},
                {field:"courseId",title:"课程编号",align:'center'},
                {field:"courseName",title:"课程名称",align:'center'},
                {field:"coursePrice",title:"原价",align:'center'},
                {field:"courseNprice",title:"现价",align:'center'},
                {field:"updateDate",title:"操作时间",align:'center'},
            ]]
        })
    }
})